﻿using DoNet.Core.Models;
using SqlSugar;

namespace DoNet.System.Models
{
    /// <summary>
    /// 
    /// </summary>
    [SugarTable("Sys_Token", "Token表")]
    [Serializable]
    public class Token : TenantEntity, ICreationAudited, IModificationAudited, IDeleteAudited
    {
        /// <summary>
        /// 
        /// </summary>
        public string AppId { get; set; } = string.Empty;
        /// <summary>
        /// 令牌
        /// </summary>
        public string AccessToken { get; set; } = string.Empty;
        /// <summary>
        /// 令牌过期时长（分钟）
        /// </summary>
        public int AccessExpires { get; set; }
        /// <summary>
        /// AccessToken过期时间（UTC）
        /// </summary>
        public DateTime AccessExpiresDate { get; set; }
        /// <summary>
        /// 刷新令牌
        /// </summary>
        public string RefreshToken { get; set; } = string.Empty;
        /// <summary>
        /// 刷新令牌过期时长（分钟）
        /// </summary>
        public int RefreshExpires { get; set; }
        /// <summary>
        /// RefreshToken过期时间（UTC）
        /// </summary>
        public DateTime RefreshExpiresDate { get; set; }

        /// <summary>
        /// 创建日期
        /// </summary>
        [SugarColumn(ColumnDescription = "创建日期")]
        public virtual DateTime? CreatorTime { get; set; }
        /// <summary>
        /// 创建用户主键
        /// </summary>
        [SugarColumn(ColumnDescription = "创建用户主键")]
        public virtual long? CreatorUserId { get; set; }

        /// <summary>
        /// 最后修改时间
        /// </summary>
        [SugarColumn(ColumnDescription = "最后修改时间", IsOnlyIgnoreInsert = true)]
        public virtual DateTime? LastModifyTime { get; set; }
        /// <summary>
        /// 最后修改用户
        /// </summary>
        [SugarColumn(ColumnDescription = "最后修改用户", IsOnlyIgnoreInsert = true)]
        public virtual long? LastModifyUserId { get; set; }

        /// <summary>
        /// 删除标志
        /// </summary>
        [SugarColumn(ColumnDescription = "删除标志")]
        public virtual bool DeleteMark { get; set; } = false;
        /// <summary>
        /// 删除时间
        /// </summary>
        [SugarColumn(ColumnDescription = "删除时间")]
        public virtual DateTime? DeleteTime { get; set; }
        /// <summary>
        /// 删除用户
        /// </summary>
        [SugarColumn(ColumnDescription = "删除用户")]
        public virtual long? DeleteUserId { get; set; }
    }
}
